<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<html>
<head>
<title></title>
<link href="<s:url value='/common/lib/ligerUI/skins/Aqua/css/ligerui-all.css'/>" rel="stylesheet" type="text/css" />
<link href="<s:url value='/common/lib/ligerUI/skins/ligerui-icons.css'/>" rel="stylesheet" type="text/css" />
<script src="<s:url value='/common/lib/jquery/jquery-1.3.2.min.js'/>" type="text/javascript"></script>
<script src="<s:url value='/common/lib/ligerUI/js/core/base.js'/>" type="text/javascript"></script>
<script src="<s:url value='/common/lib/ligerUI/js/plugins/ligerDialog.js'/>" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
    	var dc = $("#dealerCode").val();
    	var ts = $("#timeStamp").val();
    	if(dc == "" || ts == "") {
    		$("#typeBox").hide();
    		$.ligerDialog.alert('您今天尚未上传数据！', '提示', 'none');
    	}
    	
    	$("#nameBox").hide();
    	$("#infoBox").hide();
    	$("#delBox").hide();
    });
    
    function chooseType() {
    	var type = $("input[name='type']:checked").val();
    	if(type == 0 || type == 2) {
    		$("#nameBox").show();
    		$("input[value='6']").attr("checked","checked");
    		$("#delBox").show();
    		$("#sname").val("本店");
    		$("#sNameBox").hide();
    	} else {
    		$("#nameBox").hide();
    		$("#delBox").show();
    	}
    }
    
    function chooseName() {
    	var name = $("input[name='name']:checked").val();
    	if(name == 7) {
    		$("#sNameBox").show();
    		$("#sname").attr("disabled", "");
    		$("#snameIn").attr("disabled", "");
    		$("#delBox").hide();
    		$("#sname").val("");
    	} else {
    		$("#sNameBox").hide();
    		$("#delBox").show();
    		$("#sname").val("本店");
    	}
    }
    
    function inputName() {
    	var name = $("#sname").val();
    	if(name != "") {
    		var pattern=/[\/\\\:\*\?\"\<\>\|]/;
        	if(name.search(pattern) == -1) {
        		$("#sname").attr("disabled", "disabled");
        		$("#snameIn").attr("disabled", "disabled");
        		$("#delBox").show();
        	} else {
        		$.ligerDialog.alert('目录名有错，目录名不能包含\\\/:*?"<>|"！', '错误', 'none');
        	}
        } else {
        	$.ligerDialog.alert('请输入二级目录名！', '错误', 'none');
        }
    }
    
    function deleteData() {
    	var dc = $("#dealerCode").val();
    	var ts = $("#timeStamp").val();
    	var t = $("input[name='type']:checked").val();
    	var name = $("#sname").val();
    	$.ligerDialog.confirm('确定要删除该目录下的所有数据?', function (yes) {
    		if(yes) {
    			$("#delBtn").attr("disabled", "disabled");
    			$("#infoBox").show();
    			$.post("<s:url value='/record/deleteData.action'/>",{dealerCode:dc, timeStamp:ts, provedType:t,fsName:name}, function(data) {
    				$("#infoBox").hide();
    				if(data == 0) {
    					$.ligerDialog.alert('数据已删除', '提示', 'success');
    					if("本店" != name) {
    						$("#sname").val("");
    					}
    				} else if(data == 2) {
    					$.ligerDialog.alert('您还未上传该目录，请重新选择目录！', '错误', 'error');
    					if("本店" != name) {
    						$("#sname").val("");
    					}
    				} else {
    					$.ligerDialog.alert('系统忙,请稍后再试！', '提示', 'none');
    				}
    				$("#delBtn").attr("disabled", "");
    				$("#sname").attr("disabled", "");
            		$("#snameIn").attr("disabled", "");
    			});
    		}
    	});
    }
    
</script>
<style type="text/css">
	.btn {background-color:#FFF; border:1px solid #CDCDCD; height:22px; width:120px;}
</style>
</head>
<body style="padding:10px">
	<s:hidden name="dealerCode"/>
	<s:hidden name="timeStamp"/>
	
	<div id="typeBox" style="padding:2px;">
		<label id="typeLabel" style="width: 158px; height: 20px; padding:2px;">请选择要删除的数据类型：</label>
		<input type="radio" value="0" name="type" onclick="chooseType()">状态一</input>
		<input type="radio" value="1" name="type" onclick="chooseType()">状态二</input>
		<input type="radio" value="2" name="type" onclick="chooseType()">状态三</input>
		<input type="radio" value="3" name="type" onclick="chooseType()">在途已到达</input>
		<input type="radio" value="4" name="type" onclick="chooseType()">系统外</input>
		<input type="radio" value="5" name="type" onclick="chooseType()">证明材料</input>
	</div>
	
	<div id="nameBox" style="padding:2px;">
		<div>
			<label id="typeLabel" style="width: 158px; height: 20px; padding:2px;">请选择目录名称：</label>
			<input type="radio" value="6" name="name" onclick="chooseName()">本店</input>
			<input type="radio" value="7" name="name" onclick="chooseName()">二级</input>
		</div>
		<div id="sNameBox">
			<label id="typeLabel" style="width: 158px; height: 20px; padding:2px;">请输入二级目录名称：</label>
			<input type="text" id="sname" class="l-text" style="width:120px;height:20px;"/>
			<input type="button" id="snameIn" onclick="inputName()" value="确定" class="btn"/>
		</div>
	</div>
	
	<div id="delBox">
		<input type="button" id="delBtn" onclick="deleteData()" value="删除" class="btn"/>
	</div>
	
	<div id="infoBox">
			<span>正在删除... ...</span>
		</div>
</body>
</html>